<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Area_model extends CI_Model {
	function __construct(){
        parent::__construct();
    }
    
    function get_list(){
    	$key = 'rsh_area';
    	//$this->mycache->delete($key);//@todo
    	$list = $this->mycache->get_array($key);
    	if($list == false){
    		$this->db->select('id,name');
    		$query = $this->db->get('rsh_area');
    		$result = $query->result_array();
    		$list = array();
    		foreach($result as $v){
    			$list[$v['id']] = $v['name'];
    		}
    		$this->mycache->set_array($key, $list, 0);
    	}
    	return $list;
    }
    
    function get_by_pid($pid = 0){
    	$key = 'rsh_area_'.$pid;
    	//$this->mycache->delete($key);//@todo
    	$list = $this->mycache->get_array($key);
    	if($list == false){
    		$this->db->select('id,name');
    		$this->db->where('pid',$pid);
    		$query = $this->db->get('rsh_area');
    		$result = $query->result_array();
    		$list = array();
    		foreach($result as $v){
    			$list[$v['id']] = $v['name'];
    		}
    		$this->mycache->set_array($key, $list, 0);
    	}
    	return $list;
    }
    

}